-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test code for stdlib #127
Conversation
you could write code like |
echo join([\"apple\", \"banana\", \"cherry\"], \", \") | ||
} | ||
"; | ||
test_amber!(code, "apple,banana,cherry") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_amber!(code, "apple,banana,cherry") | |
test_amber!(code, "apple, banana, cherry") |
Since we join with the comma and space between - why don't we add the space there as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if multiple characters are specified for IFS
, it will only be one character when output, so for this case, I'll set it to just ,
.
src/tests/stdlib.rs
Outdated
// TODO: Unable to validate changes in exit code. | ||
#[test] | ||
fn exit() { | ||
let code = " | ||
import * from \"std\" | ||
main { | ||
exit(0) | ||
} | ||
"; | ||
test_amber!(code, "") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can leave it like that cuz it's literally running exit
command
@@ -11,6 +11,7 @@ similar-string = "1.4.2" | |||
colored = "2.0.0" | |||
itertools = "0.11.0" | |||
clap = { version = "4.4.18", features = ["derive"] } | |||
tempfile = "3.10.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This library seems to be well backed. I think it's okay
@@ -1,7 +1,7 @@ | |||
pub fun trim(text) { | |||
return "$\{{nameof text}##*( )}" | |||
return unsafe $echo "{text}" | xargs$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have unified the test_amber
macro.
As a result, the test using the trim
function in the original test_files/str/trim.ab
failed.
Therefore, I copied and pasted the definition of the trim
function from src/std/main.ab
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay then we have to fix the trim
function in a separate issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@b1ek Can you take a look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but it has a lot of repetitive code. not sure if thats a good idea to push it to master like this
src/tests/stdlib.rs
Outdated
|
||
#[test] | ||
fn file_read() { | ||
let temp_dir = tempdir().expect("Failed to create temporary directory"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repetitive code
src/tests/stdlib.rs
Outdated
|
||
#[test] | ||
fn file_write() { | ||
let temp_dir = tempdir().expect("Failed to create temporary directory"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repetitive code
src/tests/stdlib.rs
Outdated
|
||
#[test] | ||
fn file_append() { | ||
let temp_dir = tempdir().expect("Failed to create temporary directory"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repetitive code
|
||
#[test] | ||
fn file_exist() { | ||
let temp_dir = tempdir().expect("Failed to create temporary directory"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repetitive code
@b1ek Thank you for your commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Added test code for std functions.
Unaddressed Items
input
function: Couldn't figure out how to write the codetrim_left
function: Does not perform as expectedtrim_right
function: Does not perform as expectedexit
function: Unable to validate changes in exit code.I am not familiar with Rust, so please point out any problems.
Closes #117